package liangtWorkSpace.base.ifElse.factory;

import liangtWorkSpace.base.ifElse.action.Modulo;
import liangtWorkSpace.base.ifElse.action.*;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

/**
 * @ClassName OperationFactory
 * @Description : 加减乘除工厂类
 * @Author : LiangT
 * @Date : 2020/5/14 19:03
 */
public class OperationFactory {
    static Map<String, Operation> operationMap = new HashMap<>();

    static {
        operationMap.put("add",new Addition());
        operationMap.put("divide", new Division());
        operationMap.put("multiply", new Multiplication());
        operationMap.put("subtract", new Subtraction());
        operationMap.put("modulo", new Modulo());
    }
    public static Optional<Operation> getOperation(String o){
        return Optional.ofNullable(operationMap.get(o));
    }
}
